<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CMS－Prosperous</title>
<{$showjs}>
<link rel="stylesheet" type="text/css" href="./css/main.css"/>
</head>
<body>
<script>
Ext.onReady(function(){	
$("body").css({background:"#D6E2F2",color:"#fff"});
          //使用表单提示
          Ext.QuickTips.init();
          Ext.form.Field.prototype.msgTarget = 'side';
		  
		  //定义表单
          var simple = new Ext.FormPanel({
                labelAlign: 'center',
				labelWidth: 55, 			
				baseCls: 'x-plain',
				defaults: {width: 150},
				monitorValid: true,
				defaultType: 'textfield',//默认字段类型

				//定义表单元素
				items: [{
						//style:'background:url(/admin/img/Fwdw_icons_57.png) no-repeat center left',
						fieldLabel: '帐户',
						name: 'username',//元素名称
						id:'username',
						//anchor:'95%',//也可用此定义自适应宽度
						width:180,
						allowBlank:false,//不允许为空
						blankText:'帐户不能为空'//错误提示内容
					},{
					    inputType:'password',
						fieldLabel: '密码',
						//anchor:'95%',
						width:180,
						name: 'password',
						allowBlank:false,
						blankText:'密码不能为空'
					},{
					    inputType:'hidden',
						//fieldLabel: '密码',
						//anchor:'95%',
						name: 'action',
						value:'loginz'
						//allowBlank:false,
						//blankText:'密码不能为空'
					}
				],

			    keys:[{ //处理键盘回车事件   
			        key:Ext.EventObject.ENTER,   
			        fn:onOK,
			        scope:this  
			    }],

				buttons: [{
					text: '登陆',
					id:	'loginSubmit',
					type: 'submit',
							
					//定义表单提交事件
					handler:function(){
                              if(simple.form.isValid()){//验证合法后使用加载进度条
							      Ext.MessageBox.show({
									   title: '请稍等',
									   msg: '正在加载...',
									   progressText: '',
									   width:300,
									   progress:true,
									   closable:false,
									   animEl: 'loding'
								   });
								   //控制进度速度
								   var f = function(v){
									 return function(){
												var i = v/11;
												Ext.MessageBox.updateProgress(i, '');
								            };
								   };

								   for(var i = 1; i < 13; i++){
										setTimeout(f(i), i*150);
								   }
                                  
								  //提交到服务器操作
								  simple.form.doAction('submit',{
									 url:'/includes/admins.php',//文件路径
									 method:'post',//提交方法post或get
									 params:'{action:login}',
									 //提交成功的回调函数
									 success:function(form,action){
											if (action.result.msg=='ok') {
												document.location='index.php';
											} else {
												Ext.Msg.alert('登陆错误',action.result.msg);
												Ext.get('username').select();
											}
									 },
									 //提交失败的回调函数
									 failure:function(){
											Ext.Msg.alert('错误','服务器出现错误请稍后再试！');
									 }
								  });
							   }                               						   
					},formBind:true
				},{
					text: '取消',
					handler:function(){simple.form.reset();}//重置表单
				}]
			});    


			
		        	//确定按钮事件   
			        function onOK() { 
			            var but=document.getElementsByTagName("button");
						var butlen=but.length;
						for(i=0;i<butlen;i++){
							but[i].innerHTML=='登陆'?but[i].click():'';
						}
			        }

			
			       //定义窗体
				   win = new Ext.Window({
						id:'win',
						iconCls:'key',
						title:'Properous CMS User LOGIN',
						layout:'fit',	//之前提到的布局方式fit，自适应布局					
						width:300,
						height:150,
						plain:true,
                        bodyStyle:'padding:5px;',
						maximizable:false,//禁止最大化
						closeAction:'close',
						closable:false,//禁止关闭
						collapsible:true,//可折叠
						plain: true,
						buttonAlign:'center',
						items:simple//将表单作为窗体元素嵌套布局
					});
					
					win.on('show',function(){   
                        //$('username').focus();
                        Ext.get('username').focus();
                    }, this,{delay: 200}); 
					
					win.show();//显示窗体
					
                    //win.on('show',function(){TextField.focus()},this); 
                    //$(document).ready(function(){
                    //  $("#username").focus();
                    //}); 
                   

                    
										
		 });
</script>
</body>
</html>
